Merge "Avoid invidual LinkCache lookups in Linker::makeBrokenImageLinkObj()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 24 May 2016 03:29:28 +0000 (03:29 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 24 May 2016 03:29:28 +0000 (03:29 +0000)
1  2 
includes/Linker.php
tests/parser/parserTests.txt

diff --combined includes/Linker.php
@@@ -940,7 -940,15 +940,15 @@@ class Linker 
                        $redir = RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title );
  
                        if ( $redir ) {
-                               return self::linkKnown( $title, $encLabel, [], wfCgiToArray( $query ) );
+                               // We already know it's a redirect, so mark it
+                               // accordingly
+                               return self::link(
+                                       $title,
+                                       $encLabel,
+                                       [ 'class' => 'mw-redirect' ],
+                                       wfCgiToArray( $query ),
+                                       [ 'known', 'noclasses' ]
+                               );
                        }
  
                        $href = self::getUploadUrl( $title, $query );
                                $encLabel . '</a>';
                }
  
-               return self::linkKnown( $title, $encLabel, [], wfCgiToArray( $query ) );
+               return self::link( $title, $encLabel, [], wfCgiToArray( $query ), [ 'known', 'noclasses' ] );
        }
  
        /**
                if ( !$title ) {
                        $title = $wgTitle;
                }
 -              $attribs['rel'] = Parser::getExternalLinkRel( $url, $title );
 +              $newRel = Parser::getExternalLinkRel( $url, $title );
 +              if ( !isset( $attribs['rel'] ) || $attribs['rel'] === '' ) {
 +                      $attribs['rel'] = $newRel;
 +              } elseif ( $newRel !== '' ) {
 +                      // Merge the rel attributes.
 +                      $newRels = explode( ' ', $newRel );
 +                      $oldRels = explode( ' ', $attribs['rel'] );
 +                      $combined = array_unique( array_merge( $newRels, $oldRels ) );
 +                      $attribs['rel'] = implode( ' ', $combined );
 +              }
                $link = '';
                $success = Hooks::run( 'LinkerMakeExternalLink',
                        [ &$url, &$text, &$link, &$attribs, $linktype ] );
         * work if $wgShowRollbackEditCount is disabled, so this can only function
         * as an additional check.
         *
 -       * If the option noBrackets is set the rollback link wont be enclosed in []
 +       * If the option noBrackets is set the rollback link wont be enclosed in "[]".
 +       *
 +       * See the "mediawiki.page.rollback" module for the client-side handling of this link.
         *
         * @since 1.16.3. $context added in 1.20. $options added in 1.21
         *
                        $inner = $context->msg( 'brackets' )->rawParams( $inner )->escaped();
                }
  
 +              $context->getOutput()->addModules( 'mediawiki.page.rollback' );
 +
                return '<span class="mw-rollback-link">' . $inner . '</span>';
        }
  
                $query = [
                        'action' => 'rollback',
                        'from' => $rev->getUserText(),
 -                      'token' => $context->getUser()->getEditToken( [
 -                              $title->getPrefixedText(),
 -                              $rev->getUserText()
 -                      ] ),
                ];
 +              $attrs = [
 +                      'data-mw' => 'interface',
 +                      'title' => $context->msg( 'tooltip-rollback' )->text(),
 +              ];
 +              $options = [ 'known', 'noclasses' ];
 +
                if ( $context->getRequest()->getBool( 'bot' ) ) {
                        $query['bot'] = '1';
                        $query['hidediff'] = '1'; // bug 15999
                        }
  
                        if ( $editCount > $wgShowRollbackEditCount ) {
 -                              $editCount_output = $context->msg( 'rollbacklinkcount-morethan' )
 +                              $html = $context->msg( 'rollbacklinkcount-morethan' )
                                        ->numParams( $wgShowRollbackEditCount )->parse();
                        } else {
 -                              $editCount_output = $context->msg( 'rollbacklinkcount' )->numParams( $editCount )->parse();
 +                              $html = $context->msg( 'rollbacklinkcount' )->numParams( $editCount )->parse();
                        }
  
 -                      return self::link(
 -                              $title,
 -                              $editCount_output,
 -                              [ 'title' => $context->msg( 'tooltip-rollback' )->text() ],
 -                              $query,
 -                              [ 'known', 'noclasses' ]
 -                      );
 +                      return self::link( $title, $html, $attrs, $query, $options );
                } else {
 -                      return self::link(
 -                              $title,
 -                              $context->msg( 'rollbacklink' )->escaped(),
 -                              [ 'title' => $context->msg( 'tooltip-rollback' )->text() ],
 -                              $query,
 -                              [ 'known', 'noclasses' ]
 -                      );
 +                      $html = $context->msg( 'rollbacklink' )->escaped();
 +                      return self::link( $title, $html, $attrs, $query, $options );
                }
        }
  
@@@ -2265,15 -2265,6 +2265,15 @@@ Entities inside <pre
  
  !! end
  
 +!! test
 +<nowiki> inside of #tag:pre
 +!! wikitext
 +{{#tag:pre|Foo <nowiki>&rarr;bar</nowiki>}}
 +!! html
 +<pre>Foo &#8594;bar</pre>
 +
 +!! end
 +
  !! test
  <nowiki> and <pre> preference (first one wins)
  !! wikitext
@@@ -13159,7 -13150,7 +13159,7 @@@ Image with link parameter, wgExternalLi
  !! config
  wgExternalLinkTarget='foobar'
  !! html/php
 -<p><a href="http://example.com/" target="foobar" rel="nofollow"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 +<p><a href="http://example.com/" target="foobar" rel="nofollow noreferrer noopener"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
  </p>
  !! end
  
@@@ -13193,7 -13184,7 +13193,7 @@@ Image with link parameter, wgExternalLi
  !! config
  wgExternalLinkTarget='foobar'
  !! html/php
 -<p><a href="http://example.com/" title="Title" target="foobar" rel="nofollow"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 +<p><a href="http://example.com/" title="Title" target="foobar" rel="nofollow noreferrer noopener"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
  </p>
  !! end
  
@@@ -13953,7 -13944,7 +13953,7 @@@ Redirected imag
  !! wikitext
  [[Image:Barfoo.jpg]]
  !! html/php
- <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
+ <p><a href="/wiki/File:Barfoo.jpg" title="File:Barfoo.jpg" class="mw-redirect">File:Barfoo.jpg</a>
  </p>
  !! end